<template>
  <div class="shareList">
    <div class="for" v-for="(item, index) in list" :key="index">
      <div @click="gotoShare(item.id)">
        <h3 class="title">{{ item.title }}</h3>
        <p class="txt">{{ item.content }}</p>
      </div>
      <div class="box">
        <div class="left">
          <img class="imgs" :src="item.author.avatar | formatImg" alt="" />
          <span>{{ item.author.nickname }}</span>
        </div>
        <div class="right">
          <span class="span1">{{ item.create_at | formatData2 }}</span>
          <span class="iconfont iconicon_pinglunliang">{{ item.read }}</span>
          <span class="iconfont iconbtn_dianzan_small_nor">{{
            item.star
          }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { articlesShare } from '@/api/find.js'
export default {
  name: 'shareList',
  props: {
    form: {
      type: Object,
      default: () => ({})
    }
  },
  model: {
    prop: 'form'
  },
  data () {
    return {
      list: []
    }
  },
  created () {
    this.getData()
  },
  methods: {
    async getData () {
      const res = await articlesShare(this.form)
      // console.log(res)
      this.list = res.data.list
      console.log(this.list)
    },
    gotoShare (id) {
      this.$router.push('./sharedetail?id=' + id)
    }
  }
}
</script>

<style lang="less" scoped>
.shareList {
  padding-bottom: 80px;

  .for {
    margin-bottom: 32px;
  }
  .title {
    font-weight: 500;
    color: #181a39;
    font-size: 36px;
  }
  p {
    margin-top: 24px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .txt {
    font-size: 26px;
    color: #545671;
  }
  .box {
    margin-top: 24px;
    display: flex;
    font-size: 24px;
    color: #b4b4bd;
    .left {
      flex: 1;
      position: relative;
      span {
        position: absolute;
        top: 14px;
        left: 72px;
      }
      .imgs {
        width: 48px;
        height: 48px;
        border-radius: 50%;
      }
    }
    .right {
      flex: 1;
      height: 33px;
      line-height: 72px;
      .span1 {
        padding-right: 42px;
      }
      .iconfont {
        font-size: 24px;
        padding-right: 60px;
      }
    }
  }
}
</style>
